package com.qqtech.qquan.mall.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.qqtech.core.frame.model.PageKit;
import com.qqtech.core.frame.model.PageOrder;
import com.qqtech.core.frame.model.Result;
import com.qqtech.core.frame.service.BaseService;
import com.qqtech.qquan.mall.enums.MallSubjectStatusDictEnum;
import com.qqtech.qquan.mall.model.MallSubject;
import com.qqtech.qquan.mall.model.MallSubjectQuery;
import com.qqtech.qquan.mall.model.MallSubjectVo;
import com.qqtech.qquan.mall.service.MallSubjectService;
import com.qqtech.web.context.BaseWebController;

@Controller
@RequestMapping(value = "/mall/subject")
public class MallSubjectController extends BaseWebController<MallSubject, MallSubjectQuery> {
	@Resource
	private MallSubjectService mallSubjectService;
    
	@Override
	protected BaseService<MallSubject> getBaseService() {
		return mallSubjectService;
	}
	
	/**
	 * 首页展示专区列表
	 * 
	 * @param mallSubjectQuery
	 * @return
	 */
	@RequestMapping(value = "/subjectList")
	@ResponseBody
	public Result subjectList(@RequestBody MallSubjectQuery mallSubjectQuery) {
		Result result = new Result();
		Pageable pageKit = new PageKit(1, 3,new PageOrder(Direction.ASC, "oidx"));
		mallSubjectQuery.setStatus(MallSubjectStatusDictEnum.NORMAL.getCode());
		List<MallSubjectVo> subjectList = mallSubjectService.queryList(mallSubjectQuery, pageKit);
		if(subjectList != null && subjectList.size() > 0){
			result.put("subjectList", subjectList);
		}
		return result;
	}
}
